﻿//////////////////////////////////////////////////////////////////////
// <copyright file=Curve.cs">
//     Copyright (c) 2010
//     Released under  GNU GENERAL PUBLIC LICENSE
//     http://dev.perl.org/licenses/gpl1.html
// </copyright>
// <date> 3/3/2010 12:34:05 AM </date>
// <author> B. Endrovski </author>
// <web> http://furiouspixels.blogspot.com/ </web>
//////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Xml.Serialization;

namespace Curves
{
	public abstract class Curve
	{	
		[Category("Appearance")]
		[Description("Drawing color of the curve")]
		[XmlIgnore]									// Writen by the prop below
		public Color Color
		{
			get { return color; }
			set { color = value; }
		}		
		protected Color color = Color.Black;		// Static init

		// HACK - Used only for serialization purposes
		[XmlElement("Color", typeof(int))]
		[Browsable(false)]							// Hide from UI
		public int XMLColor
		{
			get { return color.ToArgb(); }
			set { color = Color.FromArgb(value); }
		}

		[Category("Appearance")]
		[Description("Drawing thikness of the curve")]
		public float Thickness
		{
			get { return thickness; }
			set { thickness = value; }
		}
		protected float thickness = 1.0f;			// Static init		

		[Category("General")]
		[Description("Display name")]
		public String Name
		{
			get { return name; }
			set { name = value; }
		}
		private String name;

		[Category("General")]
		[ReadOnly(true)]
		public int Id
		{
			get { return id; }
		}
		private int id;

		[Category("Shape")]
		public int Samples
		{
			get { return samples; }
			set { samples = value; }
		}
		protected int samples = 24;

		private static int count = 0;

		public Curve()
		{
			id = count++;
			name = "Curve" + id;
		}

		public override string ToString()
		{
			return Name;
		}


		/// <summary>
		/// Every curve should be able to be drawn on the screen using a set of samples.
		/// </summary>
		/// <param name="samples">The number of samples.
		/// Might be interpreted differently according to tessellation method.</param>
		/// <returns>A set points on the curve.</returns>
		public abstract PointF[] GetCurve();		
	}
}
